package cn.iocoder.yudao.module.engine.enums;

import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.core.StringArrayValuable;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

import java.util.Arrays;

/**
 * Sensor操作类型枚举
 */
@AllArgsConstructor
@ToString
public enum OperationTypeEnum implements StringArrayValuable {
    VOLUME_UP("VolumeUp", "音量增大"),
    VOLUME_DOWN("VolumeDown", "音量调小"),
    VOLUME_CLOSE("VolumeClose", "音量关闭"),
    JIA_JIN("JiaJin", "夹紧"),
    JIA_SONG("JiaSong", "夹松"),
    JIA_START("JiaStart", "启动夹吸"),
    JIA_STOP("JiaStop", "停止夹吸"),
    APP_STOP("AppStop", "关闭客户端"),
    APP_START("AppStart", "启动客户端"),
    ;

    public static final String[] ARRAYS = Arrays.stream(values())
            .map(OperationTypeEnum::getValue)
            .toArray(String[]::new);

    /**
     * 类型
     */
    private final String value;
    /**
     * 类型名
     */
    private final String name;

    public static OperationTypeEnum valueOf(Integer value) {
        return ArrayUtil.firstMatch(userType -> userType.getValue().equals(value), OperationTypeEnum.values());
    }

    @Override
    public String[] array() {
        return ARRAYS;
    }

    @JsonValue
    public String getValue() {
        return value;
    }

    public String getName() {
        return name;
    }
}
